Skip to main content

部署至 Vercel

Vercel 是前端框架和静态站点的平台,旨在与您的内容、商业或数据库集成。

我们提供无障碍的开发体验来处理困难的事情:即时部署、自动扩展以及在全球范围内提供个性化内容。

我们让前端团队可以轻松地开发、预览和交付令人愉悦的用户体验,其中性能是默认设置。

创建 Vercel 账户

tip
  • Vercel 网站 Vercel
  • 使用 GitHub 账户注册并登录

导入 GitHub 仓库

按照引导一步一步点击,不需要输入额外配置,一切顺利即可完成部署。 导入github仓库

配置部署图片

解析域名

tip
  • 笔者的购买域名网站: GoDaddy
  • 笔者的 DNS 解析网站: DNSPOD

转移 DNS 解析服务器

点击View Domains,输入自己购买的域名,并根据指引修改 DNS 解析。 将 GoDaddy 中默认的 DNS 解析修改为 DNSPod 域名解析需等待一定时间,笔者等待了约 30 小时。

配置 DNS 映射到 Vercel

在 Vercel 网站中,设置 Domains 解析:

在 DNSPod 中点击添加记录:

dns添加解析

Upgrading Docusaurus 版本升级

记一次 Upgrading Docusaurus from 2.0.0 to 2.4.0 on Vercel 时,当执行 yarn run build时,报错如下: typeerror: svgo.optimize is not a function

  • Tried yarn upgrade @docusaurus/core@latest @docusaurus/preset-classic@latest command
  • Tried yarn clear command
  • Tried yarn install command

Searching on Google, I found a similar issue like this,

Hi! The problem is with docusaurus-plugin-xxx. This plugin was made in the time when preset-classic was still in JS instead of TS, and when we migrated to TS, the way to import this preset has changed as well: from require('@docusaurus/preset-classic') to __importDefault(require('@docusaurus/preset-classic')). Since it seems they are already distributing a transpiled code, fixing this would just need them to build their code again, test against the latest version, and re-publish. Could you get in touch with them? For the time being, the best you can do is use patch-package to fix this package.

I try to use patch-package, but I don't know which plugin is the problem actually. I manually modified the plugin version in package.json, all upgraded to 2.4.0, and tried to deploy again, and finally the error has gone away.

"dependencies": {
...
"@docusaurus/core": "^2.4.0",
"@docusaurus/plugin-google-analytics": "^2.4.0",
"@docusaurus/plugin-google-gtag": "^2.4.0",
"@docusaurus/preset-classic": "^2.4.0",
"@docusaurus/theme-mermaid": "^2.4.0",
"@docusaurus/theme-search-algolia": "^2.4.0",
...
}

Upgrading Docusaurus to 3.5.2

Release Note:

# 太久没本地启动 yarn not found
# 更新 yarn 版本
npm install -g yarn

# 安装依赖
yarn install

# 升级版本
yarn upgrade @docusaurus/core

# 本地启动遇到问题, debug无果,删除 node_modules重新安装
rm -rf node_modules yarn.lock package-lock.json
yarn install

最大的改动是 MDX 文件的升级,需要手动修改 MDX 文件,具体参考 Docusaurus 官网|Update MDX

# 检查 mdx 文件
npx docusaurus-mdx-checker